import React, { useState } from "react";
import request from "../utils/request";

export default function Page1() {
    const [data, setData] = useState(null);

    const handleFetch = async () => {
        try {
            // 这里以 https://jsonplaceholder.typicode.com/todos/1 为例
            const res = await request.get("/mock/api/user/info");
            setData(res.data);
        } catch (err) {
            console.error(err);
            setData("请求失败");
        }
    };

    return (
        <div>
            <h2>这是菜单项1对应的页面内容</h2>
            <button onClick={handleFetch}>发起GET请求</button>
            <pre>{data ? JSON.stringify(data, null, 2) : null}</pre>
        </div>
    );
}